package com.learn.ioc.populateBean;

import org.springframework.beans.*;

import java.util.ArrayList;
import java.util.List;


public class BeanWrapperExample {
    public static void main(String[] args) {
        // 创建目标 Bean
        User user = new User();

        // 创建 BeanWrapper
        BeanWrapper beanWrapper = new BeanWrapperImpl(user);

        // 单个属性设置
        beanWrapper.setPropertyValue("name", "张三");

        // 批量属性设置
		List<PropertyValue> deepCopy = new ArrayList<>();

		deepCopy.add(new PropertyValue("age", 25));
		deepCopy.add(new PropertyValue("email", "zhangsan@example.com"));
        beanWrapper.setPropertyValues(new MutablePropertyValues(deepCopy));

        // 输出结果
        System.out.println("Name: " + user.getName());
        System.out.println("Age: " + user.getAge());
        System.out.println("Email: " + user.getEmail());
    }
}
/* Output:
Name: 张三
Age: 25
Email: zhangsan@example.com
 */

class User {
	private String name;
	private int age;
	private String email;

	// Getters and Setters
	public String getName() { return name; }
	public void setName(String name) { this.name = name; }

	public int getAge() { return age; }
	public void setAge(int age) { this.age = age; }

	public String getEmail() { return email; }
	public void setEmail(String email) { this.email = email; }
}